home *** CD-ROM | disk | FTP | other *** search
Text File | 1998-10-23 | 7.1 KB | 364 lines | [TEXT/CWIE] |
- // PopupGroupBox.cp
-
- #include <Types.h>
- #include <Quickdraw.h>
- #include <Controls.h>
- #include <Dialogs.h>
- #include <Events.h>
- #include <Lists.h>
- #include <Menus.h>
- #include <Resources.h>
- #include <Sound.h>
- #include <TextEdit.h>
- #include <ToolUtils.h>
- #include <Appearance.h>
-
- #include "Globals.h"
- #include "ResourceDefs.h"
- #include "DoScrap.h"
- #include "Miscellany.h"
- #include "Scrolling.h"
- #include "ControlUtils.h"
- #include "DDocData.h"
- #include "LayerGroupsEngine.h"
- #include "LayerGroupsDoc.h"
-
- #include "PopupGroupBox.h"
-
-
- //----------
- void PopupGroupBox::Create (
- AMDoc* inDoc,
- DDocData* inData)
- {
- PopupGroupBox* winObj = new PopupGroupBox;
-
- if (winObj != nil) {
- winObj->Open (inDoc);
- winObj->ConnectToData (inData);
- }
- }
-
- //----------
- PopupGroupBox::PopupGroupBox ()
- {
- mData = nil;
- }
-
- //----------
- PopupGroupBox::~PopupGroupBox ()
- {
- }
-
- //----------
- LayerGroupsEngine* PopupGroupBox::GetEngine ()
- {
- return (LayerGroupsEngine*) mDoc->mEngine;
- }
-
- //----------
- void PopupGroupBox::Open (
- AMDoc* inDoc)
- {
- WindowPtr window;
- Handle wftb;
-
- mDoc = inDoc;
-
- window = GetNewCWindow (WIND_PopupGroupBox, nil, (WindowPtr) -1L);
- if (mDoc->mEngine->GetFilename () [0] != 0) {
- SetWTitle (window, mDoc->mEngine->GetFilename ());
- }
- mWindow = window;
- ((LayerGroupsDoc*)mDoc)->mPopupGroupBoxPtr = window;
-
- SetWindowKind (window, 'AM');
- SetWRefCon (window, (long) this);
- SetPort (window);
- SetInfo (window);
-
- wftb = ::GetResource ('Wftb', WIND_PopupGroupBox);
-
- CreateRootControl (window, &mRootControl);
-
- vScroll = nil;
- hScroll = nil;
-
-
-
- mGroupBoxHandle = ::GetNewControl (CNTL_GroupBox, window);
- SetWindowItemFont (mGroupBoxHandle, wftb, 1);
-
- mPopupLayersHandle = ::GetNewControl (CNTL_PopupLayers, window);
- EmbedControl (mPopupLayersHandle, mGroupBoxHandle);
- SetWindowItemFont (mPopupLayersHandle, wftb, 2);
-
-
- mAlphaHandle = ::GetNewControl (CNTL_Alpha, window);
- EmbedControl (mAlphaHandle, mPopupLayersHandle);
- SetWindowItemFont (mAlphaHandle, wftb, 3);
-
- mChooseFromThePopupToSeeOtLabel = GetNewControl (CNTL_ChooseFromThePopupToSeeOt, window);
- EmbedControl (mChooseFromThePopupToSeeOtLabel, mAlphaHandle);
- SetWindowItemFont (mChooseFromThePopupToSeeOtLabel, wftb, 4);
- SetControlFromTEXT (mChooseFromThePopupToSeeOtLabel, TEXT_ChooseFromThePopupToSeeOt);
-
-
- mBetaHandle = ::GetNewControl (CNTL_Beta, window);
- EmbedControl (mBetaHandle, mPopupLayersHandle);
- SetWindowItemFont (mBetaHandle, wftb, 5);
-
- mProgressBarHandle = ::GetNewControl (CNTL_ProgressBar, window);
- EmbedControl (mProgressBarHandle, mBetaHandle);
- SetWindowItemFont (mProgressBarHandle, wftb, 6);
- SetIndeterminateState (mProgressBarHandle, true);
-
-
- mGammaHandle = ::GetNewControl (CNTL_Gamma, window);
- EmbedControl (mGammaHandle, mPopupLayersHandle);
- SetWindowItemFont (mGammaHandle, wftb, 7);
-
- mEditText3Handle = ::GetNewControl (CNTL_EditText3, window);
- EmbedControl (mEditText3Handle, mGammaHandle);
- SetWindowItemFont (mEditText3Handle, wftb, 8);
-
- AdvanceKeyboardFocus (window);
-
- ShowWindow (window);
- }
-
- //----------
- void PopupGroupBox::Close ()
- {
- mData->RemoveResponder (this);
-
- ((LayerGroupsDoc*)mDoc)->mPopupGroupBoxPtr = nil;
- SetInfo (nil);
- HideWindow (mWindow);
- DisposeWindow (mWindow);
-
- delete this;
- }
-
- //----------
- void PopupGroupBox::ConnectToData (
- DDocData* inData)
- {
- mData = inData;
- mData->AddResponder (this);
-
- SetControlValue (mGroupBoxHandle, mData->GetPopupChoice ());
- SetLayerGroupValue (mPopupLayersHandle, mData->GetPopupChoice ());
- SetControlValue (mProgressBarHandle, mData->GetProgressBar ());
- SetControlText (mEditText3Handle, mData->GetEditText3 ());
- }
-
- //----------
- void PopupGroupBox::DataChanged (
- long inDataID)
- {
- if (inDataID == idPopupChoice) {
- SetControlValue (mGroupBoxHandle, mData->GetPopupChoice ());
- }
- if (inDataID == idPopupChoice) {
- SetLayerGroupValue (mPopupLayersHandle, mData->GetPopupChoice ());
- }
- if (inDataID == idProgressBar) {
- SetControlValue (mProgressBarHandle, mData->GetProgressBar ());
- }
- if (inDataID == idEditText3) {
- SetControlText (mEditText3Handle, mData->GetEditText3 ());
- }
- }
-
- //----------
- void PopupGroupBox::Control (
- ControlHandle whichControl,
- short whichPart,
- Point where)
- {
- Rect bounds;
- short newValue;
-
- ExitCurField ();
-
- if (whichControl == mGroupBoxHandle) {
- if (HandleControlClick (mGroupBoxHandle, where,
- (short)curEvent.modifiers,
- (ControlActionUPP)(-1)) != 0) {
- mData->SetPopupChoice (GetControlValue (mGroupBoxHandle));
- }
- }
- if (whichControl == mEditText3Handle) {
- HandleEditClick (mEditText3Handle, where);
- // mData->SetEditText3 (GetEditTextChars (mEditText3Handle));
- // wait 'til exit field
- }
- }
-
- //----------
- void PopupGroupBox::MouseIn (
- Point where,
- short modifiers)
- {
- Rect bounds;
-
- }
-
- //----------
- void PopupGroupBox::ExitCurField ()
- {
- ControlHandle focus;
-
- GetKeyboardFocus (mWindow, &focus);
-
- if (focus == nil) {
- // nothing to exit
-
- } else if (focus == mEditText3Handle) {
- mData->SetEditText3 (GetEditTextChars (mEditText3Handle));
- }
- }
-
- //----------
- void PopupGroupBox::TypeIn (
- char ch)
- {
- ControlHandle focus;
- SInt16 keyCode;
-
- GetKeyboardFocus (mWindow, &focus);
-
- if ((ch == charEnter)
- || (ch == charReturn)) {
- ExitCurField ();
- } else if (ch == charEsc) {
- } else if (ch == charTab) {
- DoTab ((curEvent.modifiers & optionKey) != 0);
- } else if (focus != nil) {
- keyCode = (SInt16)(curEvent.message & keyCodeMask);
- HandleControlKey (focus, keyCode, ch, (SInt16)curEvent.modifiers);
- mDoc->mEngine->SetDirty ();
- } else {
- SysBeep (1);
- }
- }
-
- //----------
- void PopupGroupBox::Resize ()
- {
- /* application-specific code to resize items in window */
- }
-
- //----------
- void PopupGroupBox::Scroll (
- short newValue,
- short oldValue)
- {
- /* application-specific code to scroll window */
- if (gWhichScroll == vScroll) {
- } else { // horizontal
- }
- }
-
- //----------
- void PopupGroupBox::DoUndo ()
- {
- } // DoUndo
-
- //----------
- void PopupGroupBox::DoCut ()
- {
- TEHandle curTE = GetCurTE ();
-
- if (curTE != nil) {
- TECut (curTE);
- mDoc->mEngine->SetDirty ();
- scrapDirty = true;
- }
- } // DoCut
-
- //----------
- void PopupGroupBox::DoCopy ()
- {
- TEHandle curTE = GetCurTE ();
-
- if (curTE != nil) {
- TECopy (curTE);
- scrapDirty = true;
- }
- } // DoCopy
-
- //----------
- void PopupGroupBox::DoPaste ()
- {
- TEHandle curTE = GetCurTE ();
-
- if (curTE != nil) {
- TEPaste (curTE);
- mDoc->mEngine->SetDirty ();
- }
- } // DoPaste
-
- //----------
- void PopupGroupBox::DoClear ()
- {
- TEHandle curTE = GetCurTE ();
-
- if (curTE != nil) {
- TEDelete (curTE);
- mDoc->mEngine->SetDirty ();
- }
- } // DoClear
-
- //----------
- void PopupGroupBox::DoSelectAll ()
- {
- TEHandle curTE = GetCurTE ();
-
- if (curTE != nil) {
- TESetSelect (0, 32767, curTE);
- }
- } // DoSelectAll
-
- //----------
- void PopupGroupBox::DoShowClipboard ()
- {
- } // DoShowClipboard
-
- //----------
- Boolean PopupGroupBox::DoCommand (
- long inCommand)
- {
- Boolean result = true;
-
- switch (inCommand) {
- case cmdUndo:
- DoUndo ();
- break;
- case cmdCut:
- DoCut ();
- break;
- case cmdCopy:
- DoCopy ();
- break;
- case cmdPaste:
- DoPaste ();
- break;
- case cmdClear:
- DoClear ();
- break;
- case cmdSelectAll:
- DoSelectAll ();
- break;
- case cmdShowClipboard:
- DoShowClipboard ();
- break;
-
- default:
- result = false;
- } // switch
-
- return result;
- }
-